<?php
/**
 * 下载类 
 *
 */
class PageDownload
{
    const _CONST_TB_DEFAULT_   = 'block_daily_app_list_index_count';
	const _CONST_DB_SYSTEM_ = 'statistics';

    /**
     * 获得不同页面的下载数
     *
     * @return array() 
     */
	public static function page_download($page = NULL,$day = NULL)
	{
		if($day == NULL)
		{
			$day = date("Y-m-d",strtotime("-1 day"));
		}
		if($page == NULL)
		{
			$page = 'Featured';
		}

		$query = DB::select(array('SUM("list_download")','list_download'),array('SUM("detail_download")','detail_download'),'page','index','date')
			->from(self::_CONST_TB_DEFAULT_)
			->where('index','<' ,32)
			->where('date','=' ,$day)
			->where('page','=' ,$page)
			->group_by('index')
			->order_by('index','ASC')
			->execute(self::_CONST_DB_SYSTEM_);
		$rs = $query->as_array();
		return $rs;
	}

    public static function page_index($page ,$index ,$start_day ,$end_day)
    {
		$query = DB::select(array('SUM("list_download")','list_download'),array('SUM("detail_download")','detail_download'),'page','index','date')
			->from(self::_CONST_TB_DEFAULT_)
            ->where('index','=',$index)
			->where('date','>=' ,$start_day)
			->where('date','<=' ,$end_day)
			->where('page','=' ,$page)
			->order_by('date','ASC')
			->group_by('date')
			->execute(self::_CONST_DB_SYSTEM_);
		$rs = $query->as_array();
		return $rs;
    }
}
